package com.jspgou.cms.manager.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.jspgou.common.hibernate3.Updater;
import com.jspgou.common.page.Pagination;
import com.jspgou.cms.dao.ConsumerTopDao;
import com.jspgou.cms.entity.ConsumerTop;
import com.jspgou.cms.manager.ConsumerTopMng;

@Service
@Transactional
public class ConsumerTopMngImpl implements ConsumerTopMng {
	@Transactional(readOnly = true)
	public Pagination getPage(int pageNo, int pageSize) {
		Pagination page = dao.getPage(pageNo, pageSize);
		return page;
	}

	@Transactional(readOnly = true)
	public ConsumerTop findById(Long id) {
		ConsumerTop entity = dao.findById(id);
		return entity;
	}

	public ConsumerTop save(ConsumerTop bean) {
		dao.save(bean);
		return bean;
	}

	public ConsumerTop update(ConsumerTop bean) {
		Updater<ConsumerTop> updater = new Updater<ConsumerTop>(bean);
		ConsumerTop entity = dao.updateByUpdater(updater);
		return entity;
	}

	public ConsumerTop deleteById(Long id) {
		ConsumerTop bean = dao.deleteById(id);
		return bean;
	}
	
	public ConsumerTop[] deleteByIds(Long[] ids) {
		ConsumerTop[] beans = new ConsumerTop[ids.length];
		for (int i = 0,len = ids.length; i < len; i++) {
			beans[i] = deleteById(ids[i]);
		}
		return beans;
	}

	private ConsumerTopDao dao;

	@Autowired
	public void setDao(ConsumerTopDao dao) {
		this.dao = dao;
	}
}